package com.ssy.lingxi.product.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ssy.lingxi.product.entity.commodity.CommodityUnitPriceAndPic;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;

/**
 * 常购清单实体类
 * @author jw.chen
 * @version 2.0.0
 * @date 2021/10/19
 */
@Getter
@Setter
@Entity
@Table(schema = "public", name = "product_often_buy_commodity", indexes = {@Index(name = "product_often_buy_commodity_shop_id_idx", columnList = "shopId")})
public class OftenBuyCommodity implements Serializable {
    private static final long serialVersionUID = -4271743033135593017L;
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="often_buy_commodity_seq")
    @SequenceGenerator(sequenceName="product_often_buy_commodity_seq", name="often_buy_commodity_seq",allocationSize = 1)
    private Long id;

    /**
     * 商品skuId
     */
    @JsonIgnore
    @OneToOne(cascade = {CascadeType.PERSIST})
    @JoinColumn(name="commoditySkuId",referencedColumnName = "id")
    private CommodityUnitPriceAndPic commoditySku;

    /**
     * 商城id
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long shopId;

    /**
     * 已买数量
     */
    @Column(columnDefinition = "decimal", nullable = false)
    private Double buyCount;

    /**
     * 会员id
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long memberId;

    /**
     * 会员名称
     */
    @Column(columnDefinition = "varchar(50)")
    private String memberName;

    /**
     * 会员角色id
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long memberRoleId;

    /**
     * 会员角色名称
     */
    @Column(columnDefinition = "varchar(50)")
    private String memberRoleName;

    /**
     * 创建时间
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long createTime = System.currentTimeMillis();
}
